﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Interop;
using System.Runtime.InteropServices;

namespace WebViewerTest
{
	public class HiddenWebBrowser : HwndHost
	{
		private const int WM_MOUSEMOVE = 0x0200;

		private WebRenderer renderer;

		public HiddenWebBrowser()
		{
			renderer = new WebRenderer();
		}

		protected override IntPtr WndProc( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled )
		{
			if ( msg == WM_MOUSEMOVE )
			{
				Win32.User32.SendMessage( renderer.Browser.Handle, (uint)msg, wParam, lParam );
				handled = true;
			}

			return base.WndProc( hwnd, msg, wParam, lParam, ref handled );
		}

		protected override HandleRef BuildWindowCore( HandleRef hwndParent )
		{
			return new HandleRef( this, renderer.Browser.Handle );
		}

		protected override void DestroyWindowCore( System.Runtime.InteropServices.HandleRef hwnd )
		{
		}
	}
}